/**
 * 支付成功提醒页面
 */
Ext.define("PRO.shop.view.pay.payInfoView",{
    extend: 'Ext.panel.Panel',
    border:0,
    layout:'fit',
    alias: 'widget.shop.payinfoview',
    autoScroll : true,
    initComponent: function(){
        var me = this;
        me.items=[{
            xtype:'box',
            tpl:[
                '<div style="height: 100%;width: 100%;text-align: center;">',
                    '<i style="color:rgb(0,210,56);font-size: 30px;margin-top:0" class="{icon}"></i>',
                    '<p style="line-height: 30px;font-size: 12px;color:#999999;">微信扫码支付</p>',
                    '<div style="width:170px;height:170px;margin:0 auto 10px;">{img}</div>',
                    '<p style="font-size: 14px;color:#999999;">请尽快扫码支付<span style="color:#333;">{money}</span>元</p>',
                    '<tpl if="time==\'00:00\'">',
                        '<p style="font-size: 14px;margin-top: 10px;color:#999999;">已失效</p>',
                    '<tpl else>',
                        '<p style="font-size: 14px;color:#FF0136;">{time}</p>',
                    '</tpl>',
                '</div>'
            ],
            listeners:{
                afterrender:function(view){
                    var d = new Date();
                    d.setMinutes(d.getMinutes() + 30);
                    me.fnTimeCountDown(d);
                }
            }
        }];
        me.callParent(arguments);
    },
    fnTimeCountDown : function(d, o){
        var me=this;
	    var f = {
		zero: function(n){
			var n = parseInt(n, 10);
			if(n > 0){
				if(n <= 9){
					n = "0" + n;	
				}
				return String(n);
			}else{
				return "00";	
			}
		},
		dv: function(){
            d = d || Date.UTC(2050, 0, 15); 
            
            var future = new Date(d), now = new Date();
			var dur = Math.round((future.getTime() - now.getTime()) / 1000), pms = {
				sec: "00",
				mini: "00",
				hour: "00",
				day: "00",
				month: "00",
				year: "0"
			};
			if(dur > 0){
				pms.sec = f.zero(dur % 60);
				pms.mini = Math.floor((dur / 60)) > 0? f.zero(Math.floor((dur / 60)) % 60) : "00";
				pms.hour = Math.floor((dur / 3600)) > 0? f.zero(Math.floor((dur / 3600)) % 24) : "00";
				pms.day = Math.floor((dur / 86400)) > 0? f.zero(Math.floor((dur / 86400)) % 30) : "00";
				pms.month = Math.floor((dur / 2629744)) > 0? f.zero(Math.floor((dur / 2629744)) % 12) : "00";
				pms.year = Math.floor((dur / 31556926)) > 0? Math.floor((dur / 31556926)) : "0";
            }
            
			return pms;
		},
        ui: function(){
            var time=f.dv().mini+":"+f.dv().sec
            var view= me.down('box');
            var data={
                icon:me.info.icon,
                money:me.info.money,
                img:me.info.img,
                type:me.info.type,
                time:time
            }
            if(JE.isNotEmpty(view)){
                view.update(data);
            }
			setTimeout(f.ui, 1000);
		}
	};	
	f.ui();
} 
}); 

/*-------调用方法----------
icon:jeicon jeicon-alipay(支付宝)/jeicon jeicon-weixin(微信)
JE.win({
    xtype:'panel',
    layout:'fit',
    width:350,
    height:365,
    border:0,
    default:{border:0},
    items:[{xtype:'shop.payinfoview',info:{icon:'jeicon jeicon-alipay',text:'支付宝扫码支付',type:'支付宝'}}]
}).show();
*/ 